#!coding=utf-8
from __future__ import unicode_literals

from django.db import models

from Users.models import UserProfile
from Assets.models import Server
# Create your models here.


class TerminalUser(models.Model):
    user = models.ForeignKey(UserProfile)
    servers = models.ManyToManyField(Server)

    class Meta:
        verbose_name = u'终端连接'
        verbose_name_plural = verbose_name

    def __str__(self):
        return self.user.username.encode('utf8')

    def get_servers(self):
        return '；'.join([server.name for server in self.servers.all()])
    get_servers.short_description = u'可连接主机'
